<template>
	<div id="notice" class="i_maxW">
		<div class="notice_title clear">
			<div class="notice_title_l fl">
				<i>消息中心</i>
			</div>
		</div>
		<div class="notice_main clear">
			<div class="notice_nav fl">
				<div class="notice_link">
					<template v-for="(item, index) in menuNavRouteData.children">
						<el-badge class="item" v-if="item.name === 'comment' ">
							<router-link :to="'/'+menuNavRouteData.path+'/'+item.path+'/'+item.children[0].path">
								{{item.txtName}}
								<template v-for="num of number" v-if="num.type == item.newType && (num.num != 0 || number[4].num !== 0)">
									<i class="num_s">{{num.num + number[4].num}}</i>
								</template>
							</router-link>
						</el-badge>
						<el-badge class="item" v-else-if="item.name !== 'group' && user_multistage == true">
							<router-link :to="'/'+menuNavRouteData.path+'/'+item.path+'/'+item.children[0].path">
								{{item.txtName}}
								<template v-for="num of number" v-if="num.type == item.newType && num.num != 0">
									<i class="num_s">{{num.num}}</i>
								</template>
							</router-link>
						</el-badge>
						<el-badge class="item" v-else>
							<router-link :to="'/'+menuNavRouteData.path+'/'+item.path+'/'+item.children[0].path">
								{{item.txtName}}
								<template v-for="num of number" v-if="num.type == item.newType && num.num != 0">
									<i class="num_s">{{num.num}}</i>
								</template>
							</router-link>
						</el-badge>
					</template>
				</div>
			</div>
			<div class="notice-c">
				<router-view class="fade-router"></router-view>
			</div>
		</div>
	</div>
</template>
<script>
export default {
	data() {
		return {
			menuNavRouteData: deep_clone(this.$store.getters.leftMenuNav),
			activeIndex: '1',
			number: [],
			user_multistage: this.$store.state.userInfo.is_level,
		}
	},
	created() {
		this.changeNumber()
	},
	computed: {
		/*监控未读消息数量*/
		Badge() {
			return this.$store.state.newBadge;
		}
	},
	methods: {
		/*未读消息数*/
		changeNumber() {
			let success = (res => {
				this.number = res.data
				this.$store.commit('SET_NBADGE', this.number)

			});

			this.$ajax({
				url: 'api/message/message_unread_count',
				methiod: 'get',
				params: {},
				func: { success: success }
			})
		}
	},
	watch: {
		Badge(val, newval) {
			this.changeNumber()
		}
	}
}
</script>